﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImageK.Java
{
    public class IntegerUtils
    {
        /// <summary>
        ///  finds the highest set bit in an integer
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static int HighestOneBit(int number)
        {
            number |= (number >> 1);
            number |= (number >> 2);
            number |= (number >> 4);
            number |= (number >> 8);
            number |= (number >> 16);
            return number - (number >> 1);
        }
    }
}
